package com.tgy.algorithm.base._贪心;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class _全排列 {

    public static void  allRank(int[] nums,List<Integer> container,List<List<Integer>> res) {

        if (container.size() == nums.length) {
            ArrayList<Integer> integers = new ArrayList<>();
            for ( Integer integer : container) {
                integers.add(integer);
            }
            res.add(integers);
            return;
        }

        for ( int i = 0; i < nums.length; i++) {
            Integer val = nums[i];
            container.add(val);
            allRank(nums, container, res);
            container.remove(val);
        }
    }

    public static void main(String[] args) {

        List<List<Integer>> arrayList = new ArrayList<>();
        allRank(new int[]{1,2,3}, new ArrayList<>(),arrayList);
        System.out.println(arrayList);
        System.out.println(arrayList.size());
    }
}
